<template>
	<view>
		<form v-model="res">
			<view class="cu-form-group">
				<view class="title" style="min-width: 150upx;">资源名称</view>
				<view>
					<text>{{res.RES_NAME_}}</text>
				</view>
			</view>
			<view class="cu-form-group align-start">
				<view class="title" style="min-width: 150upx;">资源链接</view>
				<view style="min-height: 200upx;">
					<text user-select="true">{{res.RES_LINK_}}</text>
				</view>
			</view>
		</form>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				res: {
					RES_NAME_: '',
					RES_LINK_: ''
				}
			}
		},
		methods: {},
		onLoad(query) {
			let that = this;
			if (query.from != 'search') {
				uni.request({
					url: that.baseUrl + "/share",
					data: {
						authId: uni.getStorageSync('mini_sfshare_key'),
						resId: query.id
					},
					success(res) {
						if (res.statusCode == 200) {
							that.res = res.data;
						} else {
							uni.showToast({
								icon: 'none',
								title: '获取消息失败，请重试！',
								duration: 1200
							});
						}
					},
					fail(res) {
						uni.showToast({
							icon: 'none',
							title: '服务器开了小差，请稍后再试！',
							duration: 1200
						});
					}
				});
			} else {
				uni.request({
					url: that.baseUrl + "/res",
					data: {
						resId: query.id
					},
					success(res) {
						if (res.statusCode == 200) {
							that.res = res.data;
						} else {
							uni.showToast({
								icon: 'none',
								title: '获取消息失败，请重试！',
								duration: 1200
							});
						}
					},
					fail(res) {
						uni.showToast({
							icon: 'none',
							title: '服务器开了小差，请稍后再试！',
							duration: 1200
						});
					}
				});
			}
		}
	}
</script>

<style>

</style>
